package com.bw.zg3_day03lx.user

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ToastUtils
import com.bw.base.mvvm.BaseActivity
import com.bw.zg3_day03lx.R
import com.bw.zg3_day03lx.databinding.ActivityRegisterBinding
import dagger.hilt.android.AndroidEntryPoint
@Route(path = "/app/RegisterActivity")
@AndroidEntryPoint
class RegisterActivity : BaseActivity<ActivityRegisterBinding, UserViewModel>() {

    override fun initView() {
        binding.btnLogin.setOnClickListener {
            val uname = binding.etUsername.text.toString()
            val pwd = binding.etPassword.text.toString()
            if (uname.isNullOrEmpty() || pwd.isNullOrEmpty()){
                ToastUtils.showLong("请先输入内容")
                return@setOnClickListener
            }
            viewModel.register(uname,pwd)
        }
    }

    override fun initData() {
        viewModel.registerData.observe(this){
            finish()
        }
    }
}